import { createApp } from 'vue';
import App from './App.vue';
import router from './router'; // 导入路由
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import 'element-plus/dist/index.css'
import './style.css'
import { createPinia } from "pinia";
import { useAuthStore } from "./stores/auth";
import { getCookie } from "./utils/cookie";

const app = createApp(App);
const pinia = createPinia();

app.use(ElementPlus, {
    locale: zhCn
  })
app.use(router); // 注册路由
app.use(pinia);
app.mount('#app');

// 恢复 Token 到 Pinia
const authStore = useAuthStore();
const token = getCookie("token");
if (token) {
  authStore.setToken(token);
}